package com.wtpaint.lib.zhttp;

import android.text.TextUtils;

import java.net.MalformedURLException;
import java.net.URL;

public class HttpUrl {

    private String protocol;
    private String host;
    private String file;
    private int port;


    public HttpUrl(String url) throws MalformedURLException {
        URL mUrl = new URL(url);
        protocol = mUrl.getProtocol();
        host = mUrl.getHost();
        file = TextUtils.isEmpty(mUrl.getFile()) ? "/" : mUrl.getFile();
        port = mUrl.getPort() == -1 ? mUrl.getDefaultPort() : mUrl.getPort();
    }

    public String getProtocol() {
        return protocol;
    }

    public String getHost() {
        return host;
    }

    public String getFile() {
        return file;
    }

    public int getPort() {
        return port;
    }
}
